package com.zfzs.post.controller;

import com.zfzs.post.aop.log.Log;
import com.zfzs.post.common.bean.ResponseResult;
import com.zfzs.post.model.dto.VCodeDTO;
import com.zfzs.post.service.SmsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 发送验证码控制器
 *
 * @author ck
 * @date 2018-11-23
 */
@Slf4j
@RestController
@RequestMapping("sms/")
public class SmsController {

    @Autowired
    private SmsService smsService;

    /**
     * 发送注册验证码
     *
     * @param dto
     * @return
     */
    @Log("发送注册验证码")
    @PostMapping(value = "send_registe_code")
    public ResponseResult sendRegisteCode(@Validated @RequestBody VCodeDTO dto) {
        Map<String,String> uuid = smsService.sendRegisteCode(dto);
        return ResponseResult.ok("获取验证码成功",uuid);
    }

    /**
     * 发送登录验证码
     *
     * @param dto
     * @return
     */
    @Log("发送登录验证码")
    @PostMapping(value = "send_login_code")
    public ResponseResult sendLoginCode(@Validated @RequestBody VCodeDTO dto) {
        Map<String,String> uuid = smsService.sendLoginCode(dto);
        return ResponseResult.ok("获取验证码成功",uuid);
    }

    /**
     * 发送找回密码验证码
     *
     * @param dto
     * @return
     */
    @Log("发送找回密码验证码")
    @PostMapping(value = "send_forget_pwd_code")
    public ResponseResult sendForgetPwdCode(@Validated @RequestBody VCodeDTO dto) {
        Map<String,String> uuid = smsService.sendForgetPwdCode(dto);
        return ResponseResult.ok("获取验证码成功",uuid);
    }

    /**
     * 发送修改密码验证码
     */
    @Log("发送修改登录密码验证码")
    @PostMapping(value = "send_update_pwd_code")
    public ResponseResult sendUpdatePwdCode() {
        Map<String,String> uuid = smsService.sendUpdatePwdCode();
        return ResponseResult.ok("获取验证码成功",uuid);
    }

    /**
     *发送修改提现密码验证码
     */
    @Log("发送修改提现密码验证码")
    @PostMapping(value = "update_withdraw_pwd_code")
    public ResponseResult updateWithdrawPwdCode() {
        Map<String,String> uuid = smsService.updateWithdrawPwdCode();
        return ResponseResult.ok("获取验证码成功",uuid);
    }

    /**
     *发送找回提现密码验证码
     */
    @Log("发送找回提现密码验证码")
    @PostMapping(value = "forget_withdraw_pwd_code")
    public ResponseResult forgetWithdrawPwdCode(@Validated @RequestBody VCodeDTO dto) {
        Map<String,String> uuid = smsService.forgetWithdrawPwdCode(dto);
        return ResponseResult.ok("获取验证码成功",uuid);
    }

    /**
     * 发送实名认证验证码
     */
    @Log("发送实名认证验证码")
    @PostMapping(value = "send_verified")
    public ResponseResult sendVerified(@Validated @RequestBody VCodeDTO dto) {
        Map<String,String> uuid = smsService.sendVerified(dto);
        return ResponseResult.ok("获取验证码成功",uuid);
    }

    /**
     * 发送修改银行卡号验证码
     */
    @Log("发送修改银行卡号验证码")
    @PostMapping(value = "send_update_bank_no")
    public ResponseResult sendUpdateBankNo(VCodeDTO dto) {
        Map<String,String> uuid = smsService.sendUpdateBankNo(dto);
        return ResponseResult.ok("获取验证码成功",uuid);
    }

    /**
     * 发送修改身份证号码验证码
     */
    @Log("发送修改身份证号码验证码")
    @PostMapping(value = "send_update_card_no")
    public ResponseResult sendUpdateIdCardNo() {
        Map<String,String> uuid = smsService.sendUpdateIdCardNo();
        return ResponseResult.ok("获取验证码成功",uuid);
    }

    /**
     * 发送修改手机号码验证码
     */
    @Log("发送修改手机号码验证码")
    @PostMapping(value = "send_update_phone")
    public ResponseResult sendUpdatePhone(@Validated @RequestBody VCodeDTO dto) {
        Map<String,String> uuid = smsService.sendUpdatePhone(dto);
        return ResponseResult.ok("获取验证码成功",uuid);
    }

    /**
     * 发送修改身份证姓名验证码
     */
    @Log("发送修改身份证姓名验证码")
    @PostMapping(value = "send_update_card_name")
    public ResponseResult sendUpdateIdCardName() {
        Map<String,String> uuid = smsService.sendUpdateIdCardName();
        return ResponseResult.ok("获取验证码成功",uuid);
    }

    /**
     * 发送修改提现银行卡信息
     */
    @Log("发送修改提现银行卡信息")
    @PostMapping(value = "send_update_withdraw")
    public ResponseResult sendUpdateWithdraw(VCodeDTO dto) {
        Map<String,String> uuid = smsService.sendUpdateWithdraw(dto);
        return ResponseResult.ok("获取验证码成功",uuid);
    }

    /**
     * 验证注册时验证码接口
     * @return
     */
    @Log("验证注册时验证码接口")
    @PostMapping(value = "verified_register_code")
    public ResponseResult verifiedRegisterCode(@Validated @RequestBody Map<String,Object> params) {
        smsService.verifiedRegisterCode(params);
        return ResponseResult.ok();
    }




}